package demo16_2;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.LinkedList;
import java.util.Queue;

public class Test16_2 {
    public static void main(String[] args) {
        MyQueue myQueue = new MyQueue();
        myQueue.offer(1);
        myQueue.offer(2);
        myQueue.offer(3);
        myQueue.offer(4);
        System.out.println(myQueue.poll());
        System.out.println(myQueue.poll());
//        System.out.println(myQueue.poll());
//        System.out.println(myQueue.poll());
//        System.out.println(myQueue.poll());
        System.out.println(myQueue.peek());
        System.out.println(myQueue.size());
        System.out.println(myQueue.isEmpty());
    }

    public static void main1(String[] args) {
        //用链表实现双端队列
        Deque<Integer> deque = new LinkedList<>();
        //数组实现双端队列
        Deque<Integer> deque1 = new ArrayDeque<>();

        //双端队列实现栈
        Deque<Integer> stack = new ArrayDeque<>();

        //用链表实现普通队列
        Queue<Integer> queue = new LinkedList<>();
        //入队列
        queue.offer(1);
        queue.offer(2);
        queue.offer(3);
        //出队列
        queue.poll();//1出
        //获取队头元素
        System.out.println(queue.peek());//2
        //队列中元素个数
        System.out.println(queue.size());//2
        //队列是否为空
        System.out.println(queue.isEmpty());//false
    }
}
